package main;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.AbstractMap.SimpleEntry;

public class TrainingData
{
	private ArrayList<SimpleEntry<Sentence, Sentence>> sentences;
	private int sentencesNo;
	
	public TrainingData(String fFile, String eFile, int sentencesNo) throws IOException
	{
		sentences = new ArrayList<SimpleEntry<Sentence,Sentence>>();
		this.sentencesNo = sentencesNo;
		extractSentences(fFile, eFile);
	}
	
	private void extractSentences(String fFile, String eFile) throws IOException
	{
		BufferedReader fReader = new BufferedReader(new FileReader(fFile));
		BufferedReader eReader = new BufferedReader(new FileReader(eFile));
		int counter = 0;
		String f = fReader.readLine();
		String e = eReader.readLine();
		while ((counter < sentencesNo) && (f != null) && (e != null))
		{
			counter++;
			sentences.add(new SimpleEntry<Sentence, Sentence>(new Sentence(f), new Sentence(e)));
			
			f = fReader.readLine();
			e = eReader.readLine();
		}
		fReader.close();
		eReader.close();
	}
	
	public ArrayList<SimpleEntry<Sentence, Sentence>> getSentences()
	{
		return sentences;
	}
}
